package cn.tedu.ivos.vehicle.controller;

import cn.tedu.ivos.base.response.JsonResult;

import cn.tedu.ivos.vehicle.pojo.dto.VehicleRepairQuery;
import cn.tedu.ivos.vehicle.pojo.entity.VehicleRepair;
import cn.tedu.ivos.vehicle.pojo.vo.VehicleRepairVO;
import cn.tedu.ivos.vehicle.service.VehicleRepairService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Slf4j
@RequestMapping("v1/VehicleRepair")
@RestController
@Api(tags = "维修车辆模块")
public class VehicleRepairController {
    @Autowired
    private VehicleRepairService vehicleRepairService;

    @ApiOperation(("查询车辆"))
    @GetMapping("/selectForm")
    public JsonResult selectForm(VehicleRepairQuery query){
        log.debug("vehicleRepairQuery{}",query);
        List<VehicleRepairVO> list =vehicleRepairService.selectForm(query);
        return JsonResult.ok(list);
    }

    @ApiOperation("查询车牌号")
    @GetMapping("/selectlicense")
    public JsonResult selectLicense(){
        return JsonResult.ok(vehicleRepairService.selectLicense());
    }

    @ApiOperation("新增车辆")
    @PostMapping("/insertForm")
    public JsonResult insertForm(VehicleRepair vehicleRepair){
        log.debug("vehicleRepairQuety{}",vehicleRepair);

        vehicleRepairService.insertForm(vehicleRepair);
        return JsonResult.ok();

    }

    @ApiOperation("删除车辆")
    @PostMapping("delete/{id}")
    public JsonResult deleteForm (@PathVariable Long id){
        vehicleRepairService.delete(id);
        return JsonResult.ok();

    }


}

